﻿import java.util.Date;
import java.text.DateFormat;//抽象类 不要实例 不要用new
import java.text.SimpleDateFormat;//是DateFormat的子类 
import java.util.Calendar;
class TestDate{
	public static void main(String[] args){
		//Date的使用 和格式的控制
		Date now = new Date();
		DateFormat n1 = DateFormat.getInstance();//默认格式
		DateFormat n2 = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
		System.out.println("now is :"+now);
		System.out.println("now is :"+n1.format(now));
		System.out.println("now is :"+n2.format(now));

		Calendar now1 = Calendar.getInstance();

		System.out.println("now1 is :"+now1.get(Calendar.YEAR));//年

		String[] Month = {"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月"
		,"十一月","十二月"};

		System.out.println("now1 is :"+Month[now1.get(Calendar.MONTH)]);//月份是从0-11
		System.out.println("now1 is :"+now1.get(Calendar.DAY_OF_MONTH));//号

		String[] Week = {"","星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
		
		System.out.println("now1 is :"+Week[now1.get(Calendar.DAY_OF_WEEK)]);//星期从星期日开始 起始是1

	} 
}
